package com.credit.util.push;

import java.util.HashMap;
import java.util.Map;

import com.credit.util.push.android.AndroidCustomizedcast;

public class AndroidPush {
	
/*	private String appkey = null;
	private String appMasterSecret = null;
	private String timestamp = null;*/
	private PushClient client = new PushClient();
	
	public static Map<String,String> paramsMap = new HashMap<String,String>();
	static{
		paramsMap.put("appkey_1", "5961fa169f06fd7226001ad2");
		paramsMap.put("appMasterSecret_1", "bmacjcy0ie0og3isd9c1jy3lorhi2vgs");
		paramsMap.put("appkey_2", "5961faa765b6d60731000242");
		paramsMap.put("appMasterSecret_2", "uifctmigpzfuivtbusnqdvlalidb7chg");
	}
	
	public void sendAndroidCustomizedcast(String appType,String alias,String title,String ticker,String text) throws Exception {
		AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(paramsMap.get("appkey_"+appType),paramsMap.get("appMasterSecret_"+appType));
		// TODO Set your alias here, and use comma to split them if there are multiple alias.
		// And if you have many alias, you can also upload a file containing these alias, then 
		// use file_id to send customized notification.
		
		
		System.out.println("推送title:"+title+",text:"+text+",alias:"+alias+",ticker:"+ticker);
		
		customizedcast.setAlias(alias, "xmqd_push");
		customizedcast.setTicker(ticker);
		customizedcast.setTitle(title);
		customizedcast.setText(text);
		customizedcast.goAppAfterOpen();
		customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
		// TODO Set 'production_mode' to 'false' if it's a test device. 
		// For how to register a test device, please see the developer doc.
		customizedcast.setProductionMode();
		boolean bool = client.send(customizedcast);
		System.out.println(bool);
	}
	
	public static void main(String[] args) throws Exception{
		AndroidPush push = new AndroidPush();
		push.sendAndroidCustomizedcast("2", "2", "测试", "我就测测！", "有新的单子发布，请赶快去抢单");
	}

}
